<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>while循环语句</title>
    <script type="text/javascript">

        /*
        var money=1000;
        var count=0;
        while (money<=5000){
            money=money * 1.05;
            count++;
        }
        console.log(money);
        console.log("一共需要"+count+"年");
        */

        while(true){
            var testScores = prompt("请输入小明的期末成绩：");
            if(testScores>=0 && testScores<=100){
                break;
            }
            alert("请输入有效值");  
        }
        if (testScores > 100 || testScores < 0 || isNaN(testScores)) {
            alert("不是合法值");
        } else if (testScores == 100) {
            alert("奖励一台车");
        } else if (testScores >= 80) {
            alert("奖励一台手机");
        } else if (testScores >= 60) {
            alert("奖励一本书");
        } else {
            alert("什么奖励也没有");
        }


    </script>
</head>

<body>
</body>

</html>